import java.util.Scanner;

public class Test {
    //先对字符串整体进行逆置
    //再将每个单词进行逆置
    public static String reverseSentence(String str) {
        char[] array = str.toCharArray();
        char tmp;
        int end = array.length-1;
        int start = 0;
        while(start < end) {
            tmp = array[start];
            array[start] = array[end];
            array[end] = tmp;
            start++;
            end--;
        }
        start = 0;
        for (int tp = 0; tp < array.length; tp++) {
            if(tp == array.length-1 ) {
                end = tp;
                while(start < end) {
                    tmp = array[start];
                    array[start] = array[end];
                    array[end] = tmp;
                    start++;
                    end--;
                }
            } else if(array[tp] == ' ') {
                end = tp-1;
                while(start < end) {
                    tmp = array[start];
                    array[start] = array[end];
                    array[end] = tmp;
                    start++;
                    end--;
                }
                start = tp + 1;
            }
        }
        //array.toString()：实际上调用的是Object类的toString()方法，它返回的是对象的哈希码表示，而不是数组内容。
        //new String(array)：创建包含字符内容的新字符串对象,使用String的构造函数
        return new String(array);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        System.out.println(reverseSentence(str));
    }
}
